import { Component, OnInit, ViewChild, Input, Output, EventEmitter } from '@angular/core';
import { HttpService, SupDic, GridComponent } from 'lbf';
import { SFComponent, SFSchema } from '@delon/form';
import { STColumn } from '@delon/abc';
import { NzMessageService } from 'ng-zorro-antd';


@Component({
  selector: 'lb-dw',
  templateUrl: './lb_dw.html',
})
export class DwComponent implements OnInit {
  @Output() clickItem = new EventEmitter<string>();
  _dad017 = 0;
  isAddVisible = false;
  dwxzSchema: SFSchema = {
    properties: {
      AAB045: { type: 'string', title: '统一信用代码' },
      AAB004: { type: 'string', title: '单位名称' },
      AAB016: { type: 'string', title: '单位联系人' },
      AAB018: { type: 'string', title: '单位联系人电话' },
      AAE006: { type: 'string', title: '单位地址' },
    },
  };

  dwjbxxSchema: SFSchema = {
    properties: {
      AAB045: { type: 'string', title: '统一信用代码' },
      AAB004: { type: 'string', title: '单位名称' },
      DAD032: { type: 'string', title: '对象', ui: { hidden: true } },
    },
  };

  dwcolumns: STColumn[] = [
    { title: '', index: 'RN', width: '20px' },
    { title: '单位名称', index: 'AAB004', width: '50px' },
    { title: '统一信用代码', index: 'AAB045', width: '100px' },
    { title: '单位联系人', index: 'AAB016', width: '50px' },
    { title: '单位联系人电话', index: 'AAB018', width: '50px' },
    { title: '单位地址', index: 'AAE006', width: '100px' },
    {
      title: '操作区',
      width: '50px',
      buttons: [
        {
          text: '办理',
          click: (record: any) => this.tysjsl(record),
        },
      ],
    },
  ];

  params = { sname: 'JBXX_QUERY', queryparas: { DAD032: '1' } };

  
  @ViewChild('sf2', { static: false }) sf1: SFComponent;
  @ViewChild('st1', { static: false }) st: GridComponent;
  
  @Input() set ZT(value:number) {
    this._zt = value
    this.reset();    
  }
  _zt

  reset(){
    this.sf1.reset();
    this.jbxxcx();
    // console.log('aaaaa');
  }

  tysjsl(record:any) {
    this.clickItem.emit(record);
  }

  handleCancel() {
    this.isAddVisible = false;
  }

  handleOkAdd() {
    
    this.lbservice.lbservice('FR_XXADD', {}).then(resdata => {
      if (resdata.code < 1) {
        this.msgSrv.error(resdata.errmsg);
      } else {
        this.msgSrv.info('新增成功');
      }
    });
  }

  // 基本信息查询
  jbxxcx() {
    this.sf1.setValue('/DAD032', '1');
    this.st.reload(this.sf1.value);
  }
  // 基本信息新增按钮
  xzjbxx() {    
    this.isAddVisible = true;
  }

 
  
  constructor(
    private lbservice: HttpService,
    private supDic: SupDic,
    public msgSrv: NzMessageService,
  ) {
    
  }

  ngOnInit() {
    
  }


}